package com.hrt.datasender.datastorage.strategy.monitordata;

import java.util.Calendar;
import java.util.Date;

import org.quartz.JobExecutionContext;

import com.btcode.db.executer.IDataExecuter;
import com.btcode.db.sqlparameter.SQLParameterList;
import com.btcode.schedule.ScheduleManager;
import com.btcode.schedule.SingleInstanceJob;
import com.hrt.db.DBManager;

public class S10MINUTESClear extends SingleInstanceJob {

    public void registerJob() {
        ScheduleManager.getInstance().addJob(S10MINUTESClear.class, "0 30 3 * * ?");
    }

    @Override
    public void initJob(JobExecutionContext arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void myExecute(JobExecutionContext arg0) {
        IDataExecuter dataExecuter = DBManager.getDataExecuter();
        String sql = " DELETE FROM BD_S10_MINUTES WHERE DATATIME < @date  ";
        SQLParameterList pc = new SQLParameterList();
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.YEAR, -1);
        Date date = cal.getTime();
        pc.put("date", date);
        dataExecuter.delete(sql, pc);
    }

}
